# Maintainer: Johannes Löthberg <johannes@kyriasis.com>
# Contributor: Anatol Pomozov
# Contributor: kpcyrd <git@rxv.cc>
# Contributor: Frederik “Freso” S. Olesen <freso.dk@gmail.com>
# Contributor: Ian Naval <ianonavy@gmail.com>

pkgname=kubo
pkgver=0.24.0
pkgrel=1
pkgdesc='IPFS implementation in Go'
url='https://github.com/ipfs/kubo'
arch=(loong64 x86_64)
license=(MIT)
depends=(glibc)
makedepends=(go git)
optdepends=('fuse2: for mounting/advanced use')
provides=('go-ipfs')
replaces=('go-ipfs')
conflicts=('go-ipfs')
source=(https://github.com/ipfs/${pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz
        ipfs.service
        ipfs@.service)
sha512sums=('304edd85a281d0f7a797aec38a26d49ca2c4d8bf2dea7eea014b495b9ea2414e4ae277397dc7611288636713962e6c178a274ec3974f8a25bee95c3d62b88d2b'
            'b1d0b2ab3008adcd2c1871fe3ff57aa27cf43d6acbd4ab330f0d2efbba661a046b9c8a8cf514ddf131c5fce93ca5d91d10d516c4f39d98f33e4ac46aee1d0abb'
            'a1254e40d0bacfceb92071de7f5331cd87cc454bf70be34e892af35dfc677fcf130903577c2a4e7fe6da6b5cedecb22dc0f73d1ad86f5aa27a8333d6bd85fe8c')

build() {
  cd "${pkgname}-${pkgver}"

  export CGO_LDFLAGS="$LDFLAGS"
  export CGO_CFLAGS="$CFLAGS"
  export CGO_CPPFLAGS="$CPPFLAGS"
  export CGO_CXXFLAGS="$CXXFLAGS"
  export GOFLAGS="-buildmode=pie -trimpath -modcacherw"
  make build
  cmd/ipfs/ipfs commands completion bash > "$srcdir/ipfs-completion.bash"
  cmd/ipfs/ipfs commands completion fish > "$srcdir/ipfs-completion.fish"
}

package() {
  cd "${pkgname}-${pkgver}"

  install -Dm 755 cmd/ipfs/ipfs "$pkgdir/usr/bin/ipfs"
  install -Dm 644 "$srcdir"/ipfs.service "$pkgdir/usr/lib/systemd/user/ipfs.service"
  install -Dm 644 "$srcdir"/ipfs@.service "$pkgdir/usr/lib/systemd/system/ipfs@.service"

  install -Dm 644 "$srcdir"/ipfs-completion.bash "$pkgdir/usr/share/bash-completion/completions/ipfs"
  install -Dm 644 "$srcdir"/ipfs-completion.fish "$pkgdir/usr/share/fish/vendor_completions.d/ipfs.fish"

  install -Dm 644 -t "$pkgdir/usr/share/licenses/$pkgname/MIT" LICENSE-MIT
  install -Dm 644 -t "$pkgdir/usr/share/licenses/$pkgname/APACHE" LICENSE-APACHE
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
}

# vim: ts=2 sw=2 et:
